<?php
$amenities_obj = new Amenity();

function show_amenities(){
	global $amenities_obj, $KToolBar;
	$amenities = $amenities_obj->find("all");
	
	include_once 'views/amenities.html.php';
}

function new_amenity(){
	global $KToolBar;
	include_once 'views/amenities_new.html.php';
}

function save_amenity(){
	global $amenities_obj, $notice;
	$notice['error'] = 1;
	if(empty($_POST['amenity'])){
		$notice['msg'] = "You cannot leave the name field empty";
	}
	$notice = $amenities_obj->insert_or_update($_POST['amenity'], "");
	if($notice['error'] == 0) $notice['msg'] = "A new amenity has been created";
}

function delete_amenities(){
	global $amenities_obj, $notice;
	$notice['error'] = 1;
	$notice = delete_selected_items($_POST['amenities'], $amenities_obj);
	if($notice['error'] == 0) $notice['msg'] = "The selected items have been deleted";
	else $notice['msg'] = "There is some error deleting the amenities. Please try again later.";
}
?>